/*
 * servo.c
 *  Created on: Sep 9, 2025
 *      Author: 周九霄
 */

#include "peripherals_pwm_1_config.h"
#include "servo.h"

uint32_t servo_angle(float angle)
{
    if (angle < 0.0f) angle = 0.0f;
    if (angle > 180.0f) angle = 180.0f;
    g_stPwm4Config0.duty = (uint32_t)(1638.0f + angle * (8192.0f - 1638.0f) / 180.0f);  //
    return g_stPwm4Config0.duty;
}
